
<?php
session_start();
$User_ID=$_SESSION['User_ID'];
?>

<?php

require_once("includes/database.php"); 

$pet_ID_picture = $_POST['pet_ID_picture'];
$target_dir = "pet_picture/.$pet_ID_picture";
$target_file = $target_dir . basename($_FILES["fileToUpload_Pet"]["name"]);
$ext = pathinfo($target_file,PATHINFO_EXTENSION);


move_uploaded_file($_FILES["fileToUpload_Pet"]["tmp_name"],"pet_picture/" . $pet_ID_picture.".".$ext);//actually reponsible for copying file in new folder

$filenameimage="../upload_image/" . $pet_ID_picture.".".$ext;
$actualimageurl="../upload_image/" . $_FILES["fileToUpload_Pet"]["name"];



{	


$tsql="UPDATE pet_info_db SET Pet_Picture= 'pet_picture/{$pet_ID_picture}.{$ext}'
WHERE Pet_ID='{$pet_ID_picture}'";

//sendEmail(getEmail($owner_User_ID_add),"Updated Immunization Date","From Petformance");

$data =  mysql_query($tsql,$con);

if( $data )
{
    /*echo "Connection established.\n";*/
	 $message = "Uploading Picture of your Pet Successful!";
	 echo "<script type='text/javascript'>alert('$message');window.location = 'thesis_user_page.php?page=1&pet_id=';</script>";
}
else
{
   $message = "Uploading Picture of your Pet Failed.!";
	 echo "<script type='text/javascript'>alert('$message');window.location = 'thesis_user_page.php?page=1&pet_id=';</script>";
     die( print_r( mysql_error(), true));
}
}

?>